package com.accp.vehiclecare.action.hzaction;


import com.accp.vehiclecare.biz.hzbiz.ghbiz;
import com.accp.vehiclecare.pojo.Enginetype;
import com.accp.vehiclecare.vo.hzvo.Serviceitem;
import com.accp.vehiclecare.vo.hzvo.Serviceitemtype;
import com.accp.vehiclecare.vo.hzvo.Supplieras;
import com.accp.vehiclecare.vo.hzvo.goodssource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/gh")
public class ghaction {
    @Autowired
    private ghbiz ghbiz;
    @GetMapping("show1")
    public List<Supplieras> show1() throws Exception {
        return ghbiz.showSupplieras1();
    }
    @GetMapping("show2/{id}")
    public List<goodssource> show2(@PathVariable Integer id) throws Exception {
        return ghbiz.showlist(id);
    }
    @DeleteMapping("del/{id}")
    public Map<String, Object> deletePersonById(@PathVariable Integer id) {
        ghbiz.deletegoodssource(id);
        Map<String, Object> message = new HashMap<String, Object>();
        message.put("code", "200");
        message.put("msg", "ok");
        return message;
    }
    @PostMapping("add")
    public Map<String, Object> addPerson(@RequestBody goodssource goodssource) {
        ghbiz.addgoodssource(goodssource);
        Map<String, Object> message = new HashMap<String, Object>();
        message.put("code", "200");
        message.put("msg", "ok");
        return message;
    }
    @GetMapping("show3/{id}")
    public goodssource show23(@PathVariable Integer id) throws Exception {
        return ghbiz.queryonegoodssource(id);
    }
    @PutMapping("update2/{id}")
    public Map<String, Object> update2(@RequestBody goodssource goodssource, @PathVariable Integer id) {
        ghbiz.updategoodssource(goodssource,id);
        Map<String, Object> message = new HashMap<String, Object>();
        message.put("code", "200");
        message.put("msg", "ok");
        return message;
    }
}
